package com.feri.gpstudy.controller;

import com.feri.gpstudy.bo.UserAddBo;
import com.feri.gpstudy.bo.UserWhereBo;
import com.feri.gpstudy.entity.User;
import com.feri.gpstudy.service.intf.UserService;
import com.feri.gpstudy.vo.R;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 千锋郑州Java学科欢迎你
 * @program: GpStudy
 * @description: 控制层实现常用的外部接口
 * @author: Feri
 * @create: 2023-04-21 09:59:58
 */
@RestController
@RequestMapping("/api/user/")
public class UserController{
    /**
    * 注入业务逻辑层对象*/
    @Resource
    private UserService service;
    /**
    * 新增内容*/
    @PostMapping("save.do")
    public R save(@RequestBody UserAddBo bo){
       return service.save(bo);
    }
    /**
    * 修改内容*/
    @PostMapping("update.do")
    public R update(@RequestBody User user){
        return service.update(user);
    }
    /**
    * 查询 所有数据*/
    @GetMapping("all.do")
    public R all(UserWhereBo bo){
       return service.queryAll(bo);
    }
    /**
    * 查询 所有数据*/
    @GetMapping("single.do")
    public R single(long id){
        return service.queryById(id);
    }
    /**
    * 删除 单个数据*/
    @PostMapping("del.do")
    public R del(@RequestBody Map<String,Integer> map){
        return service.del(map.get("id"));
    }
}
